.class final Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;
.super Ljava/lang/Object;
.source "NioClientSocketPipelineSink.java"

# interfaces
.implements Ljava/lang/Runnable;


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x12
    name = "Boss"
.end annotation


# static fields
.field static final synthetic $assertionsDisabled:Z


# instance fields
.field private final registerTaskQueue:Ljava/util/Queue;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Queue",
            "<",
            "Ljava/lang/Runnable;",
            ">;"
        }
    .end annotation
.end field

.field volatile selector:Ljava/nio/channels/Selector;

.field private final startStopLock:Ljava/lang/Object;

.field private started:Z

.field private final subId:I

.field final synthetic this$0:Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;

.field private final wakenUp:Ljava/util/concurrent/atomic/AtomicBoolean;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 175
    const-class v0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;

    invoke-virtual {v0}, Ljava/lang/Class;->desiredAssertionStatus()Z

    move-result v0

    if-nez v0, :cond_0

    const/4 v0, 0x1

    :goto_0
    sput-boolean v0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->$assertionsDisabled:Z

    return-void

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method constructor <init>(Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;I)V
    .locals 1
    .parameter
    .parameter "subId"

    .prologue
    .line 184
    iput-object p1, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->this$0:Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 180
    new-instance v0, Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicBoolean;-><init>()V

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->wakenUp:Ljava/util/concurrent/atomic/AtomicBoolean;

    .line 181
    new-instance v0, Ljava/lang/Object;

    invoke-direct {v0}, Ljava/lang/Object;-><init>()V

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->startStopLock:Ljava/lang/Object;

    .line 182
    const-class v0, Ljava/lang/Runnable;

    invoke-static {v0}, Lorg/jboss/netty/util/internal/QueueFactory;->createQueue(Ljava/lang/Class;)Ljava/util/concurrent/BlockingQueue;

    move-result-object v0

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->registerTaskQueue:Ljava/util/Queue;

    .line 185
    iput p2, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->subId:I

    .line 186
    return-void
.end method

.method private close(Ljava/nio/channels/SelectionKey;)V
    .locals 3
    .parameter "k"

    .prologue
    .line 413
    invoke-virtual {p1}, Ljava/nio/channels/SelectionKey;->attachment()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;

    .line 414
    .local v0, ch:Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;
    iget-object v1, v0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;->worker:Lorg/jboss/netty/channel/socket/nio/NioWorker;

    invoke-static {v0}, Lorg/jboss/netty/channel/Channels;->succeededFuture(Lorg/jboss/netty/channel/Channel;)Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v2

    invoke-virtual {v1, v0, v2}, Lorg/jboss/netty/channel/socket/nio/NioWorker;->close(Lorg/jboss/netty/channel/socket/nio/NioSocketChannel;Lorg/jboss/netty/channel/ChannelFuture;)V

    .line 415
    return-void
.end method

.method private connect(Ljava/nio/channels/SelectionKey;)V
    .locals 4
    .parameter "k"

    .prologue
    .line 398
    invoke-virtual {p1}, Ljava/nio/channels/SelectionKey;->attachment()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;

    .line 400
    .local v0, ch:Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;
    :try_start_0
    iget-object v2, v0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;->socket:Ljava/nio/channels/SocketChannel;

    invoke-virtual {v2}, Ljava/nio/channels/SocketChannel;->finishConnect()Z

    move-result v2

    if-eqz v2, :cond_0

    .line 401
    invoke-virtual {p1}, Ljava/nio/channels/SelectionKey;->cancel()V

    .line 402
    iget-object v2, v0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;->worker:Lorg/jboss/netty/channel/socket/nio/NioWorker;

    iget-object v3, v0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;->connectFuture:Lorg/jboss/netty/channel/ChannelFuture;

    invoke-virtual {v2, v0, v3}, Lorg/jboss/netty/channel/socket/nio/NioWorker;->register(Lorg/jboss/netty/channel/socket/nio/NioSocketChannel;Lorg/jboss/netty/channel/ChannelFuture;)V
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0

    .line 410
    :cond_0
    :goto_0
    return-void

    .line 404
    :catch_0
    move-exception v1

    .line 405
    .local v1, t:Ljava/lang/Throwable;
    iget-object v2, v0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;->connectFuture:Lorg/jboss/netty/channel/ChannelFuture;

    invoke-interface {v2, v1}, Lorg/jboss/netty/channel/ChannelFuture;->setFailure(Ljava/lang/Throwable;)Z

    .line 406
    invoke-static {v0, v1}, Lorg/jboss/netty/channel/Channels;->fireExceptionCaught(Lorg/jboss/netty/channel/Channel;Ljava/lang/Throwable;)V

    .line 407
    invoke-virtual {p1}, Ljava/nio/channels/SelectionKey;->cancel()V

    .line 408
    iget-object v2, v0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;->worker:Lorg/jboss/netty/channel/socket/nio/NioWorker;

    invoke-static {v0}, Lorg/jboss/netty/channel/Channels;->succeededFuture(Lorg/jboss/netty/channel/Channel;)Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v3

    invoke-virtual {v2, v0, v3}, Lorg/jboss/netty/channel/socket/nio/NioWorker;->close(Lorg/jboss/netty/channel/socket/nio/NioSocketChannel;Lorg/jboss/netty/channel/ChannelFuture;)V

    goto :goto_0
.end method

.method private processConnectTimeout(Ljava/util/Set;J)V
    .locals 8
    .parameter
    .parameter "currentTimeNanos"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/Set",
            "<",
            "Ljava/nio/channels/SelectionKey;",
            ">;J)V"
        }
    .end annotation

    .prologue
    .line 368
    .local p1, keys:Ljava/util/Set;,"Ljava/util/Set<Ljava/nio/channels/SelectionKey;>;"
    const/4 v0, 0x0

    .line 369
    .local v0, cause:Ljava/net/ConnectException;
    invoke-interface {p1}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v2

    .local v2, i$:Ljava/util/Iterator;
    :cond_0
    :goto_0
    invoke-interface {v2}, Ljava/util/Iterator;->hasNext()Z

    move-result v4

    if-eqz v4, :cond_2

    invoke-interface {v2}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/nio/channels/SelectionKey;

    .line 370
    .local v3, k:Ljava/nio/channels/SelectionKey;
    invoke-virtual {v3}, Ljava/nio/channels/SelectionKey;->isValid()Z

    move-result v4

    if-eqz v4, :cond_0

    .line 382
    invoke-virtual {v3}, Ljava/nio/channels/SelectionKey;->attachment()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;

    .line 383
    .local v1, ch:Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;
    iget-wide v4, v1, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;->connectDeadlineNanos:J

    const-wide/16 v6, 0x0

    cmp-long v4, v4, v6

    if-lez v4, :cond_0

    iget-wide v4, v1, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;->connectDeadlineNanos:J

    cmp-long v4, p2, v4

    if-ltz v4, :cond_0

    .line 386
    if-nez v0, :cond_1

    .line 387
    new-instance v0, Ljava/net/ConnectException;

    .end local v0           #cause:Ljava/net/ConnectException;
    const-string v4, "connection timed out"

    invoke-direct {v0, v4}, Ljava/net/ConnectException;-><init>(Ljava/lang/String;)V

    .line 390
    .restart local v0       #cause:Ljava/net/ConnectException;
    :cond_1
    iget-object v4, v1, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;->connectFuture:Lorg/jboss/netty/channel/ChannelFuture;

    invoke-interface {v4, v0}, Lorg/jboss/netty/channel/ChannelFuture;->setFailure(Ljava/lang/Throwable;)Z

    .line 391
    invoke-static {v1, v0}, Lorg/jboss/netty/channel/Channels;->fireExceptionCaught(Lorg/jboss/netty/channel/Channel;Ljava/lang/Throwable;)V

    .line 392
    iget-object v4, v1, Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;->worker:Lorg/jboss/netty/channel/socket/nio/NioWorker;

    invoke-static {v1}, Lorg/jboss/netty/channel/Channels;->succeededFuture(Lorg/jboss/netty/channel/Channel;)Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v5

    invoke-virtual {v4, v1, v5}, Lorg/jboss/netty/channel/socket/nio/NioWorker;->close(Lorg/jboss/netty/channel/socket/nio/NioSocketChannel;Lorg/jboss/netty/channel/ChannelFuture;)V

    goto :goto_0

    .line 395
    .end local v1           #ch:Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;
    .end local v3           #k:Ljava/nio/channels/SelectionKey;
    :cond_2
    return-void
.end method

.method private processRegisterTaskQueue()V
    .locals 2

    .prologue
    .line 342
    :goto_0
    iget-object v1, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->registerTaskQueue:Ljava/util/Queue;

    invoke-interface {v1}, Ljava/util/Queue;->poll()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/Runnable;

    .line 343
    .local v0, task:Ljava/lang/Runnable;
    if-nez v0, :cond_0

    .line 349
    return-void

    .line 347
    :cond_0
    invoke-interface {v0}, Ljava/lang/Runnable;->run()V

    goto :goto_0
.end method

.method private processSelectedKeys(Ljava/util/Set;)V
    .locals 3
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/Set",
            "<",
            "Ljava/nio/channels/SelectionKey;",
            ">;)V"
        }
    .end annotation

    .prologue
    .line 352
    .local p1, selectedKeys:Ljava/util/Set;,"Ljava/util/Set<Ljava/nio/channels/SelectionKey;>;"
    invoke-interface {p1}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, i:Ljava/util/Iterator;,"Ljava/util/Iterator<Ljava/nio/channels/SelectionKey;>;"
    :cond_0
    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_2

    .line 353
    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/nio/channels/SelectionKey;

    .line 354
    .local v1, k:Ljava/nio/channels/SelectionKey;
    invoke-interface {v0}, Ljava/util/Iterator;->remove()V

    .line 356
    invoke-virtual {v1}, Ljava/nio/channels/SelectionKey;->isValid()Z

    move-result v2

    if-nez v2, :cond_1

    .line 357
    invoke-direct {p0, v1}, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->close(Ljava/nio/channels/SelectionKey;)V

    goto :goto_0

    .line 361
    :cond_1
    invoke-virtual {v1}, Ljava/nio/channels/SelectionKey;->isConnectable()Z

    move-result v2

    if-eqz v2, :cond_0

    .line 362
    invoke-direct {p0, v1}, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->connect(Ljava/nio/channels/SelectionKey;)V

    goto :goto_0

    .line 365
    .end local v1           #k:Ljava/nio/channels/SelectionKey;
    :cond_2
    return-void
.end method


# virtual methods
.method register(Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;)V
    .locals 11
    .parameter "channel"

    .prologue
    const/4 v10, 0x1

    .line 189
    new-instance v1, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$RegisterTask;

    invoke-direct {v1, p0, p1}, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$RegisterTask;-><init>(Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;Lorg/jboss/netty/channel/socket/nio/NioClientSocketChannel;)V

    .line 192
    .local v1, registerTask:Ljava/lang/Runnable;
    iget-object v6, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->startStopLock:Ljava/lang/Object;

    monitor-enter v6

    .line 193
    :try_start_0
    iget-boolean v5, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->started:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    if-nez v5, :cond_3

    .line 196
    :try_start_1
    invoke-static {}, Ljava/nio/channels/Selector;->open()Ljava/nio/channels/Selector;

    move-result-object v2

    .local v2, selector:Ljava/nio/channels/Selector;
    iput-object v2, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->selector:Ljava/nio/channels/Selector;
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0
    .catch Ljava/lang/Throwable; {:try_start_1 .. :try_end_1} :catch_0

    .line 203
    const/4 v3, 0x0

    .line 205
    .local v3, success:Z
    :try_start_2
    iget-object v5, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->this$0:Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;

    iget-object v5, v5, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;->bossExecutor:Ljava/util/concurrent/Executor;

    new-instance v7, Lorg/jboss/netty/util/ThreadRenamingRunnable;

    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    const-string v9, "New I/O client boss #"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    iget-object v9, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->this$0:Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;

    iget v9, v9, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;->id:I

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v8

    const/16 v9, 0x2d

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;

    move-result-object v8

    iget v9, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->subId:I

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    invoke-direct {v7, p0, v8}, Lorg/jboss/netty/util/ThreadRenamingRunnable;-><init>(Ljava/lang/Runnable;Ljava/lang/String;)V

    invoke-static {v5, v7}, Lorg/jboss/netty/util/internal/DeadLockProofWorker;->start(Ljava/util/concurrent/Executor;Ljava/lang/Runnable;)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_1

    .line 209
    const/4 v3, 0x1

    .line 211
    if-nez v3, :cond_0

    .line 214
    :try_start_3
    invoke-virtual {v2}, Ljava/nio/channels/Selector;->close()V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0
    .catch Ljava/lang/Throwable; {:try_start_3 .. :try_end_3} :catch_2

    .line 218
    :goto_0
    const/4 v2, 0x0

    :try_start_4
    iput-object v2, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->selector:Ljava/nio/channels/Selector;

    .line 227
    .end local v3           #success:Z
    :cond_0
    :goto_1
    sget-boolean v5, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->$assertionsDisabled:Z

    if-nez v5, :cond_4

    if-eqz v2, :cond_1

    invoke-virtual {v2}, Ljava/nio/channels/Selector;->isOpen()Z

    move-result v5

    if-nez v5, :cond_4

    :cond_1
    new-instance v5, Ljava/lang/AssertionError;

    invoke-direct {v5}, Ljava/lang/AssertionError;-><init>()V

    throw v5

    .line 232
    .end local v2           #selector:Ljava/nio/channels/Selector;
    :catchall_0
    move-exception v5

    monitor-exit v6
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_0

    throw v5

    .line 197
    :catch_0
    move-exception v4

    .line 198
    .local v4, t:Ljava/lang/Throwable;
    :try_start_5
    new-instance v5, Lorg/jboss/netty/channel/ChannelException;

    const-string v7, "Failed to create a selector."

    invoke-direct {v5, v7, v4}, Lorg/jboss/netty/channel/ChannelException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v5
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0

    .line 211
    .end local v4           #t:Ljava/lang/Throwable;
    .restart local v2       #selector:Ljava/nio/channels/Selector;
    .restart local v3       #success:Z
    :catchall_1
    move-exception v5

    if-nez v3, :cond_2

    .line 214
    :try_start_6
    invoke-virtual {v2}, Ljava/nio/channels/Selector;->close()V
    :try_end_6
    .catchall {:try_start_6 .. :try_end_6} :catchall_0
    .catch Ljava/lang/Throwable; {:try_start_6 .. :try_end_6} :catch_1

    .line 218
    :goto_2
    const/4 v2, 0x0

    :try_start_7
    iput-object v2, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->selector:Ljava/nio/channels/Selector;

    .line 211
    :cond_2
    throw v5

    .line 224
    .end local v2           #selector:Ljava/nio/channels/Selector;
    .end local v3           #success:Z
    :cond_3
    iget-object v2, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->selector:Ljava/nio/channels/Selector;

    .restart local v2       #selector:Ljava/nio/channels/Selector;
    goto :goto_1

    .line 229
    :cond_4
    const/4 v5, 0x1

    iput-boolean v5, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->started:Z

    .line 230
    iget-object v5, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->registerTaskQueue:Ljava/util/Queue;

    invoke-interface {v5, v1}, Ljava/util/Queue;->offer(Ljava/lang/Object;)Z

    move-result v0

    .line 231
    .local v0, offered:Z
    sget-boolean v5, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->$assertionsDisabled:Z

    if-nez v5, :cond_5

    if-nez v0, :cond_5

    new-instance v5, Ljava/lang/AssertionError;

    invoke-direct {v5}, Ljava/lang/AssertionError;-><init>()V

    throw v5

    .line 232
    :cond_5
    monitor-exit v6
    :try_end_7
    .catchall {:try_start_7 .. :try_end_7} :catchall_0

    .line 234
    iget-object v5, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->wakenUp:Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v6, 0x0

    invoke-virtual {v5, v6, v10}, Ljava/util/concurrent/atomic/AtomicBoolean;->compareAndSet(ZZ)Z

    move-result v5

    if-eqz v5, :cond_6

    .line 235
    invoke-virtual {v2}, Ljava/nio/channels/Selector;->wakeup()Ljava/nio/channels/Selector;

    .line 237
    :cond_6
    return-void

    .line 215
    .end local v0           #offered:Z
    .restart local v3       #success:Z
    :catch_1
    move-exception v4

    .line 216
    .restart local v4       #t:Ljava/lang/Throwable;
    :try_start_8
    sget-object v7, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;->logger:Lorg/jboss/netty/logging/InternalLogger;

    const-string v8, "Failed to close a selector."

    invoke-interface {v7, v8, v4}, Lorg/jboss/netty/logging/InternalLogger;->warn(Ljava/lang/String;Ljava/lang/Throwable;)V

    goto :goto_2

    .line 215
    .end local v4           #t:Ljava/lang/Throwable;
    :catch_2
    move-exception v4

    .line 216
    .restart local v4       #t:Ljava/lang/Throwable;
    sget-object v5, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;->logger:Lorg/jboss/netty/logging/InternalLogger;

    const-string v7, "Failed to close a selector."

    invoke-interface {v5, v7, v4}, Lorg/jboss/netty/logging/InternalLogger;->warn(Ljava/lang/String;Ljava/lang/Throwable;)V
    :try_end_8
    .catchall {:try_start_8 .. :try_end_8} :catchall_0

    goto :goto_0
.end method

.method public run()V
    .locals 14

    .prologue
    const/4 v13, 0x0

    .line 240
    const/4 v7, 0x0

    .line 241
    .local v7, shutdown:Z
    iget-object v6, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->selector:Ljava/nio/channels/Selector;

    .line 242
    .local v6, selector:Ljava/nio/channels/Selector;
    invoke-static {}, Ljava/lang/System;->nanoTime()J

    move-result-wide v3

    .line 244
    .local v3, lastConnectTimeoutCheckTimeNanos:J
    :goto_0
    iget-object v9, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->wakenUp:Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-virtual {v9, v13}, Ljava/util/concurrent/atomic/AtomicBoolean;->set(Z)V

    .line 247
    const-wide/16 v9, 0x1f4

    :try_start_0
    invoke-virtual {v6, v9, v10}, Ljava/nio/channels/Selector;->select(J)I

    move-result v5

    .line 277
    .local v5, selectedKeyCount:I
    iget-object v9, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->wakenUp:Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-virtual {v9}, Ljava/util/concurrent/atomic/AtomicBoolean;->get()Z

    move-result v9

    if-eqz v9, :cond_0

    .line 278
    invoke-virtual {v6}, Ljava/nio/channels/Selector;->wakeup()Ljava/nio/channels/Selector;

    .line 281
    :cond_0
    invoke-direct {p0}, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->processRegisterTaskQueue()V

    .line 283
    if-lez v5, :cond_1

    .line 284
    invoke-virtual {v6}, Ljava/nio/channels/Selector;->selectedKeys()Ljava/util/Set;

    move-result-object v9

    invoke-direct {p0, v9}, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->processSelectedKeys(Ljava/util/Set;)V

    .line 288
    :cond_1
    invoke-static {}, Ljava/lang/System;->nanoTime()J

    move-result-wide v0

    .line 289
    .local v0, currentTimeNanos:J
    sub-long v9, v0, v3

    const-wide/32 v11, 0x1dcd6500

    cmp-long v9, v9, v11

    if-ltz v9, :cond_2

    .line 290
    move-wide v3, v0

    .line 291
    invoke-virtual {v6}, Ljava/nio/channels/Selector;->keys()Ljava/util/Set;

    move-result-object v9

    invoke-direct {p0, v9, v0, v1}, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->processConnectTimeout(Ljava/util/Set;J)V

    .line 299
    :cond_2
    invoke-virtual {v6}, Ljava/nio/channels/Selector;->keys()Ljava/util/Set;

    move-result-object v9

    invoke-interface {v9}, Ljava/util/Set;->isEmpty()Z

    move-result v9

    if-eqz v9, :cond_6

    .line 300
    if-nez v7, :cond_3

    iget-object v9, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->this$0:Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;

    iget-object v9, v9, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;->bossExecutor:Ljava/util/concurrent/Executor;

    instance-of v9, v9, Ljava/util/concurrent/ExecutorService;

    if-eqz v9, :cond_5

    iget-object v9, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->this$0:Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;

    iget-object v9, v9, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;->bossExecutor:Ljava/util/concurrent/Executor;

    check-cast v9, Ljava/util/concurrent/ExecutorService;

    invoke-interface {v9}, Ljava/util/concurrent/ExecutorService;->isShutdown()Z

    move-result v9

    if-eqz v9, :cond_5

    .line 303
    :cond_3
    iget-object v10, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->startStopLock:Ljava/lang/Object;

    monitor-enter v10
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_1

    .line 304
    :try_start_1
    iget-object v9, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->registerTaskQueue:Ljava/util/Queue;

    invoke-interface {v9}, Ljava/util/Queue;->isEmpty()Z

    move-result v9

    if-eqz v9, :cond_4

    invoke-virtual {v6}, Ljava/nio/channels/Selector;->keys()Ljava/util/Set;

    move-result-object v9

    invoke-interface {v9}, Ljava/util/Set;->isEmpty()Z

    move-result v9

    if-eqz v9, :cond_4

    .line 305
    const/4 v9, 0x0

    iput-boolean v9, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->started:Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 307
    :try_start_2
    invoke-virtual {v6}, Ljava/nio/channels/Selector;->close()V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_1
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0

    .line 312
    const/4 v9, 0x0

    :try_start_3
    iput-object v9, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->selector:Ljava/nio/channels/Selector;

    .line 314
    :goto_1
    monitor-exit v10
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    .line 338
    return-void

    .line 308
    :catch_0
    move-exception v2

    .line 309
    .local v2, e:Ljava/io/IOException;
    :try_start_4
    sget-object v9, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;->logger:Lorg/jboss/netty/logging/InternalLogger;

    const-string v11, "Failed to close a selector."

    invoke-interface {v9, v11, v2}, Lorg/jboss/netty/logging/InternalLogger;->warn(Ljava/lang/String;Ljava/lang/Throwable;)V
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_1

    .line 312
    const/4 v9, 0x0

    :try_start_5
    iput-object v9, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->selector:Ljava/nio/channels/Selector;

    goto :goto_1

    .line 318
    .end local v2           #e:Ljava/io/IOException;
    :catchall_0
    move-exception v9

    monitor-exit v10
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0

    :try_start_6
    throw v9
    :try_end_6
    .catch Ljava/lang/Throwable; {:try_start_6 .. :try_end_6} :catch_1

    .line 326
    .end local v0           #currentTimeNanos:J
    .end local v5           #selectedKeyCount:I
    :catch_1
    move-exception v8

    .line 327
    .local v8, t:Ljava/lang/Throwable;
    sget-object v9, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink;->logger:Lorg/jboss/netty/logging/InternalLogger;

    const-string v10, "Unexpected exception in the selector loop."

    invoke-interface {v9, v10, v8}, Lorg/jboss/netty/logging/InternalLogger;->warn(Ljava/lang/String;Ljava/lang/Throwable;)V

    .line 332
    const-wide/16 v9, 0x3e8

    :try_start_7
    invoke-static {v9, v10}, Ljava/lang/Thread;->sleep(J)V
    :try_end_7
    .catch Ljava/lang/InterruptedException; {:try_start_7 .. :try_end_7} :catch_2

    goto/16 :goto_0

    .line 333
    :catch_2
    move-exception v9

    goto/16 :goto_0

    .line 312
    .end local v8           #t:Ljava/lang/Throwable;
    .restart local v0       #currentTimeNanos:J
    .restart local v5       #selectedKeyCount:I
    :catchall_1
    move-exception v9

    const/4 v11, 0x0

    :try_start_8
    iput-object v11, p0, Lorg/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink$Boss;->selector:Ljava/nio/channels/Selector;

    throw v9

    .line 316
    :cond_4
    const/4 v7, 0x0

    .line 318
    monitor-exit v10
    :try_end_8
    .catchall {:try_start_8 .. :try_end_8} :catchall_0

    goto/16 :goto_0

    .line 321
    :cond_5
    const/4 v7, 0x1

    goto/16 :goto_0

    .line 324
    :cond_6
    const/4 v7, 0x0

    goto/16 :goto_0
.end method
